package engine.config;

import java.util.HashMap;

public class ConfigEngine
{
    
    private HashMap<String, Config> cfgMap;
    
    public ConfigEngine()
    {
        this.cfgMap = new HashMap<>();
    }
    
    public Config loadConfig(String fileName)
    {
        Config cfgFile = new Config(fileName);
        this.cfgMap.put(fileName, cfgFile);
        return cfgFile;
    }
    
    public Config getConfig(String fileName)
    {
        return this.cfgMap.get(fileName);
    }
    
    public void unloadConfig(String fileName)
    {
        Config toDelete = this.getConfig(fileName);
        if (toDelete != null)
        {
            toDelete.destroy();
            this.cfgMap.remove(fileName);
        }
    }
    
    public void destroy()
    {
        this.cfgMap.clear();
        this.cfgMap = null;
    }
    
}
